package com.swallow.auth.infrastructure.acl.oauth2.support.sms;

import lombok.Getter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.core.AuthorizationGrantType;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * @author: yangjie.deng@resico.cn
 * @since: 2024-05-15 09:50:20
 * @version: v1.0.0
 * @describe: 短信登录转换后的Authentication
 */
@Getter
public class SmsGrantAuthenticationToken extends AbstractAuthenticationToken {

    private final Set<String> scopes;

    /**
     * 客户端认证信息
     */
    private final Authentication clientPrincipal;

    /**
     * 当前请求的参数
     */
    private final Map<String, Object> additionalParameters;

    /**
     * 认证方式
     */
    private final AuthorizationGrantType authorizationGrantType;

    public SmsGrantAuthenticationToken(Collection<? extends GrantedAuthority> authorities,
                                       Set<String> scopes,
                                       Authentication clientPrincipal,
                                       Map<String, Object> additionalParameters,
                                       AuthorizationGrantType authorizationGrantType) {
        super(authorities);
        this.scopes = scopes;
        this.clientPrincipal = clientPrincipal;
        this.additionalParameters = additionalParameters;
        this.authorizationGrantType = authorizationGrantType;
    }

    @Override
    public Object getCredentials() {
        return null;
    }

    @Override
    public Object getPrincipal() {
        return clientPrincipal;
    }
}
